AC: Air conditioner control
This module is the vehicle air conditioning control module. This module is provided in EdgerOS 2.0.0 and later, and apps need to have vehicle.cockpit
permission to use this module.
User can use the following code to import the AC
module.
var AC = require('vehicle/ac');
Support
The following shows AC
module APIs available for each permissions.
User Mode | Privilege Mode | |
---|---|---|
AC | ● | ● |
ac.request | ● | ● |
ac.release | ● | ● |
ac.info | ● | ● |
ac.temperature | ● | ● |
ac.blower | ● | ● |
ac.control | ● | ● |
AC Class
new AC()
- Returns: {Object} AC object.
Create a AC object.
AC Object
ac.request(callback)
callback
{Function} Callback.error
{Error} Specify the error message when the request is failed.
Request for vehicle air conditioning operation. After the request is successful, the vehicle air conditioner information can be obtained and the air conditioner can be controlled.
ac.release()
Release the current AC
object, no operation is allowed after the object is released.
The object needs to be released as soon as possible when it is no longer used.
ac.info(callback)
callback
{Function} Callback.error
{Error} Specify the error message when failed.info
{Object} Air conditioner information.
Get air conditioning information. The info
object contains the following members:
Member | Type | Description |
---|---|---|
airCondSt | Integer | 0 : OFF 1 : ON |
insideTemp | Number | Temperature inside the car |
outsideTemp | Number | Temperature outside the car |
lhTemp | String | Left front temperature |
rhTemp | String | Right front temperature |
blowerModSt | Integer | Blower mode. |
blowerSpd | Integer | Blower speed. (0 - 10 ) 0 : Stop |
cycleThr | Integer | 0 : Internal circulation 100 : External circulation (0 -100 ) |
The temperature string (lhTemp
and rhTemp
) information contains the following possible:
'LOW'
, '16.5'
, '17'
, '17.5'
, '18'
, '18.5'
, '19'
, '19.5'
, '20'
, '20.5'
, '21'
, '21.5'
, '22'
, '22.5'
, '23'
, '23.5'
, '24'
, '24.5'
, '25'
, '25.5'
, '26'
, '26.5'
, '27'
, '27.5'
, '28'
, '28.5'
, '29'
, '29.5'
, '30'
, '30.5'
, '31'
, '31.5'
, 'HIGH'
Blower mode: blowerModSt
has the following types:
Value | Description |
---|---|
1 | Face |
2 | Foot |
3 | Window |
4 | Face & Foot |
5 | Face & Window |
6 | Foot & Window |
7 | Face & Foot & Window |
The info
object may also contains the following members:
Optional Member | Type | Description |
---|---|---|
leftChnlExptTemp | Integer | Left channel outlet expected temperature |
rightChnlExptTemp | Integer | Right channel outlet expected temperature |
leftBlowerFaceAirOutTemp | Integer | Air outlet temperature on the left blowing face |
rightBlowerFaceAirOutTemp | Integer | Air outlet temperature on the right blowing face |
leftBlowerFootAirOutTemp | Integer | Air outlet temperature on the left blowing foot |
rightBlowerFootAirOutTemp | Integer | Air outlet temperature on the right blowing foot |
Example
var AC = require('vehicle/ac');
var ac = new AC();
ac.request(error => {
if (error == undefined) {
ac.info((error, info) => {
if (info) {
console.log(info);
}
});
}
});
ac.temperature(temp, callback)
temp
{Object} Temperature object.callback
{Function} Callback.error
{Error} Specify the error message when an error occurs.
Set the interior temperature. temperature object can contain the following members:
lhTemp
{String} Left front temperature.rhTemp
{String} Right front temperature.
Example
ac.temperature({
lhTemp: '24.5', rhTemp: 'LOW'
}, error => {
if (error) {
console.error(error);
}
});
ac.blower(param, callback)
param
{Object} Blower parameter object.callback
{Function} Callback.error
{Error} Specify the error message when an error occurs.
Set blower parameters:
blowerModSt
{Integer} Blower mode.blowerSpd
{Integer} Blower speed. (0
-10
)
Example
ac.blower({
blowerModSt: 4, blowerSpd: 2
}, error => {
if (error) {
console.error(error);
}
});
ac.control(param, callback)
param
{Object} Control parameter object.callback
{Function} Callback.error
{Error} Specify the error message when an error occurs.
Control air conditioner:
airCondSt
{Integer}0
: OFF1
: ON.auto
{Boolean} Whether to automatically turn on and off the air conditioner according to the temperature.cycleThr
{Integer}0
: Internal circulation100
: External circulation.
Example
ac.control({
airCondSt: 0, auto: true, cycleThr: 80
}, error => {
if (error) {
console.error(error);
}
});
AC Object Events
The ac
object inherits from the EventEmitter
class. The following events are thrown in some specific situations.
info
When the state of the air conditioner changes, this event will be generated.
Example
ac.on('info', info => {
console.log(info);
});